<template>
  <view class="input-container">
	<view class="top-view"></view>
    <!-- 输入组织ID -->
    <view class="input-section">
      <text class="input-title">请输入组织ID</text>
      <view class="input-wrap">
        <input 
          class="org-input"
          type="text"
          v-model="codeNoId"
          placeholder="请输入组织ID"
		  placeholder-style="color: #B5B5B5"
        />
      </view>
    </view>

    <!-- 查询按钮 -->
    <view class="button-section">
      <button class="gvr-yellow-button input-button" @click="handleQuery">查询</button>
    </view>
	<view class="bottom-view"></view>
  </view>
</template>

<script setup>
import { ref,onMounted} from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { userStore } from '@/utils/userStore.js'
import { RouterMethods } from '../../utils/router'
import { USER_TYPES } from '@/service/api'
// 用户信息
const userInfo = ref({
	type:''
})
onMounted(() => {
  console.log('选择组织 onMounted')
  initUserInfo()
})

// 页面显示时检查状态
onShow(() => {
  console.log("选择组织 onShow")
  initUserInfo()
})
// 初始化用户信息
const initUserInfo = () => {
  const storedInfo = userStore.getUserInfo()
  if (storedInfo) {
    userInfo.value = storedInfo
  }
}
	

const codeNoId = ref('Y5957d06')

const handleQuery = () => {
  if (!codeNoId.value) {
    uni.showToast({
      title: '请输入组织ID',
      icon: 'none'
    })
    return
  }
  // 这里添加查询逻辑
  console.log('查询组织ID:', codeNoId.value)
  if (userInfo.value.type == USER_TYPES.GAS ) {
	  RouterMethods.toGasDetail(codeNoId.value)
  } else if(userInfo.value.type == USER_TYPES.MAINTENANCE) {
	  RouterMethods.toRepairerDetail(codeNoId.value)
  }
}
</script>

<style scoped>
.input-container {
  min-height: 100vh;
  background-color: #FFFFFF;
  padding: 58rpx;
  box-sizing: border-box;
  width: 100%;
}

.input-section {
  margin-top: 414rpx;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.input-title {
  width: 100%;
  text-align: center;
  font-family: PingFangSC-Medium;
  font-size: 32rpx;
  color: #000000;
  letter-spacing: 0;
  text-align: center;
  font-weight: 500;
  margin-bottom: 38rpx;
}

.input-wrap {
  width: 100%;
  margin-bottom: 78rpx;
  border-bottom: 2rpx solid #001E32;
}

.org-input {
  width: 100%;
  height: 60rpx;
  font-family: PingFangSC-Medium;
  font-size: 28rpx;
  color: #000000;
  letter-spacing: 0;
  font-weight: 500;
  margin-bottom: 13rpx;
}
.button-section {
/*  width: 470rpx; */
  display: flex;
  align-items: center;
}
.input-button {
  width: 470rpx;
}

/* 底部按钮区域样式修改 */
.bottom-view {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 12rpx;
  padding-bottom: env(safe-area-inset-bottom);
  background-color: #001E32;
}

.top-view {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 12rpx;
  background-color: #001E32;
}

</style>